import { Router } from 'express'
import { generateImage } from '../services/imageGeneration.js'

export const imageRouter = Router()

// POST /api/image/generate - Generate image from prompt
imageRouter.post('/generate', async (req, res, next) => {
  try {
    const { prompt } = req.body as { prompt?: string }
    
    if (!prompt || typeof prompt !== 'string') {
      res.status(400).json({
        success: false,
        error: 'Prompt is required',
      })
      return
    }
    
    const result = await generateImage(prompt)
    res.json(result)
  } catch (error) {
    next(error)
  }
})
